package com.xyhy.core.jackson.serial;

import java.io.IOException;
import java.time.LocalDateTime;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.xyhy.core.utils.time.LocalDateUtil;

public class LocalDateTime4UTCSerializer extends StdSerializer<LocalDateTime> {
  private static final long serialVersionUID = 1L;

  public final static LocalDateTime4UTCSerializer instance = new LocalDateTime4UTCSerializer();

  protected LocalDateTime4UTCSerializer(Class<LocalDateTime> t) {
    super(t);
  }

  protected LocalDateTime4UTCSerializer() {
    this(null);
  }

  @Override
  public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider provider) throws IOException {
    gen.writeString(LocalDateUtil.getTimestamp(value).toString());
  }

}
